package com.ydd.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/*
* 公共字段填充*/
@Component
public class MpMetaobjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.setFieldValByName("createBy",UserUtil.getUsername(),metaobject);
        this.setFieldValByName("createDate", LocalDateTime.now(), metaObject);
//        this.setFieldValByName("updateBy",UserUtil.getUsername(),metaobject);
        this.setFieldValByName("updateDate", LocalDateTime.now(), metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.setFieldValByName("createBy",UserUtil.getUsername(),metaobject);
        this.setFieldValByName("createDate", LocalDateTime.now(), metaObject);
//        this.setFieldValByName("updateBy",UserUtil.getUsername(),metaobject);
        this.setFieldValByName("updateDate", LocalDateTime.now(), metaObject);
    }

}

